﻿using Coldairarrow.Business;
using Coldairarrow.Business.Base_AutoReplys;
using Coldairarrow.Entity.Base_AutoReplys;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base_AutoReplys
{
    [Route("/Base_AutoReplys/[controller]/[action]")]
    public class Base_ARGroupController : BaseApiController
    {
        #region DI

        public Base_ARGroupController(IBase_ARGroupBusiness base_ARGroupBus)
        {
            _base_ARGroupBus = base_ARGroupBus;
        }

        IBase_ARGroupBusiness _base_ARGroupBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<Base_ARGroup>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _base_ARGroupBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<Base_ARGroup> GetTheData(IdInputDTO input)
        {
            return await _base_ARGroupBus.GetTheDataAsync(input.Id);
        }

        /// <summary>
        /// 获取所有回复分组列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<Base_ARGroup>> GetGroupListData()
        {
            return await _base_ARGroupBus.GetListDataAsnyc();
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(Base_ARGroup data)
        {
            data.Deleted = false;
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _base_ARGroupBus.AddDataAsync(data);
            }
            else
            {
                await _base_ARGroupBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _base_ARGroupBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}